/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Form;

import BussinessLogic.Entity.Student;
import java.util.ArrayList;
import javax.swing.table.AbstractTableModel;
import javax.xml.bind.annotation.XmlElement.DEFAULT;


public class StudentModel extends AbstractTableModel{
    ArrayList<Student> stdlist = null;
    private String[] title ={"StudentRoll","StudentName","Class","Adress"};
    private Class[] Class ={String.class,String.class,String.class,String.class};
    
    public StudentModel(ArrayList<Student> stdl){
        this.stdlist = stdl;
    }

    public int getRowCount() {
        return stdlist.size();
    }

    public int getColumnCount() {
        return title.length;
    }

    public Object getValueAt(int rowIndex, int columnIndex) {
        switch(columnIndex){
            case 0:
                return stdlist.get(rowIndex).getStdRoll();
            case 1:
                return stdlist.get(rowIndex).getStdName();
            case 2:
                return stdlist.get(rowIndex).getStdClass();
            case 3:
                return stdlist.get(rowIndex).getStdAddess();
            default:
                return null;
                        
        }
    }
    @Override
    public String getColumnName(int column){
        return title[column];
    }
    public void add(Student std){
        stdlist.add(std);
        fireTableDataChanged();
    }
    

}
